﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace TorrentLaunch
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// 

        static string classID = "ClassID.TorrentLaunch";

        [STAThread]
        static void Main(String []args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!FileAssociation.IsAssociated(".torrent", classID))
            {
                if (MessageBox.Show("TorrentLaunch is currently not associated with .torrent files. Do you want to do this now?", "TorrentLaunch", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    FileAssociation.Associate(".torrent", classID, "TorrentLaunch", "", Application.ExecutablePath);
                }
            }

            if (args.Length != 1)
            {
                ConfigForm form = new ConfigForm();
                form.Config.Load();
                if (form.ShowDialog() == DialogResult.OK)
                    form.Config.Save();
            }
            else
            {
                Application.Run(new MainForm(args));
            }
        }
    }
}
